#include <G4ParticleDefinition.hh>
#include <G4ParticleGun.hh>
#include <G4ParticleTable.hh>
#include <G4ThreeVector.hh>

#include "PrimaryGeneratorAction.hh"

PrimaryGeneratorAction::PrimaryGeneratorAction() {
	rayGun = new G4ParticleGun(1);
	G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
	G4ParticleDefinition *particle = particleTable->FindParticle("mu-");
	rayGun->SetParticleDefinition(particle);
	rayGun->SetParticleTime(0);
	rayGun->SetParticleEnergy(4 * GeV);
	rayGun->SetParticlePosition(G4ThreeVector(0, 0, 1.49 * m));
	rayGun->SetParticleMomentumDirection(G4ThreeVector(sin(0 * deg / radian), 0, -cos(0 * deg / radian)));
}

PrimaryGeneratorAction::~PrimaryGeneratorAction() {
	delete rayGun;
}

void PrimaryGeneratorAction::GeneratePrimaries(G4Event *event) {
	rayGun->GeneratePrimaryVertex(event);
}
